package cn.wh.org.service.impl;

import cn.wh.basic.service.impl.BaseServiceImpl;
import cn.wh.org.domain.Details;
import cn.wh.org.domain.DictionaryType;
import cn.wh.org.mapper.DetailsMapper;
import cn.wh.org.mapper.DictionaryTypeMapper;
import cn.wh.org.service.IDictionaryTypeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

@Service
public class DictionaryTypeServiceImpl extends BaseServiceImpl<DictionaryType> implements IDictionaryTypeService {

    @Autowired
    private DictionaryTypeMapper dictionaryTypeMapper;

    @Autowired
    private DetailsMapper detailsMapper;

    @Override
    @Transactional
    public void removeById(Long id) {

        List<Details> list = detailsMapper.loadAll();
        for (Details type : list) {
            if (type.getTypes_id() == id){
                detailsMapper.deleteById(type.getId());
            }
        }
        dictionaryTypeMapper.deleteById(id);
    }

}
